www.gusucode.com > 环保时代家庭财务管理系统 EPffms v4.0 > 环保时代家庭财务管理系统 EPffms v4.0\code\eptimehome\admin_manager.asp

    <!--#include file="admin_inc.asp"-->
<%
'****************************************************
'Code for EptimeFFMS
'Vision : v4.0
'****************************************************
viewHead "家庭成员管理" & "-" & menuList(3,0)

dim action : action = getForm("action", "get")
dim errorInfo,errorPwd : errorInfo="信息填写不完整,请检查" : errorPwd="两次密码不一致"
Select  case action
	case "del" : delmanager
	case "delall" : delAll
	case "edit" : main : edit
	case "save" : saveEdit
	case "add" : addManager
	case else : main : add
End Select 
viewFoot

dim id
Sub main
	dim dataListObj,managerArray,i,n,m_id
	id=getForm("id","get")
	set dataListObj =  mainClassobj.createObject("MainClass.DataList")
	dataListObj.orderStr = "ID"
	dataListObj.tableStr = "{pre}Admin"
	managerArray = dataListObj.getDataList()
	if isArray(managerArray) then  
		n=ubound(managerArray,2)
%>
<div id="append_parent"></div>
<div class="container" id="cpcontainer">
<!--当前导航-->
<script type="text/JavaScript">if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='系统首页&nbsp;&raquo;&nbsp;<%=menuList(3,0)%>&nbsp;&raquo;&nbsp;家庭成员管理';</script>
<form  method="post" name="managerform">
<table class="tb">
<tr class="thead"><th colspan="9">家庭成员管理</th></tr>
    <TR align="center">
      <TD>ID</TD>
      <TD>用户名</TD>
	  <TD>真实名</TD>
	  <TD>生日</TD>
       <TD>最近登录时间</TD>
       <TD>最近登陆IP</TD>
       <TD>家庭成员级别</TD>
       <TD>状态</TD>
      <TD>操作</TD>
    </TR>
		<%
        for i=0 to n
            m_id= trim(managerArray(0,i))
        %>
     <TR<%if id=m_id then %> class="editlast"<%end if%> align="center">
      <TD><input type="checkbox" value="<%=m_id%>" name="m_id" class="checkbox" /><%=m_id%></TD>
      <TD><%=managerArray(1,i)%></TD>
	  <TD><%=managerArray(10,i)%></TD>
<TD><%=managerArray(11,i)%></TD>
      <TD><%isCurrentDay(managerArray(5,i))%></TD>
      <TD><%=managerArray(6,i)%> </TD>
      <TD><%=getManagerLevel(managerArray(3,i))%></TD>
      <TD><%=getManagerState(managerArray(4,i))%></TD>
      <TD><a   href="?action=edit&id=<%=m_id%>">编辑</a>&nbsp;&nbsp;<a onclick="if(confirm('确定要删除吗')){return true;}else{return false;}" href="?action=del&id=<%=m_id%>">删除</font></TD>
    </TR>
		<%
        next
        %>
          <tr><td colspan="7">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'input','m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('input','m_id')" /><input type="submit" value="批量删除" onclick="if(confirm('确定要批量删除吗')){managerform.action='?action=delall';}else{return false}" class="btn"  />&nbsp;&nbsp;</td></tr>
</TABLE>
</form> 
<%
	else
		echo "<table align='center' width='90%'><tr><td><font color='red'>没有任何记录</font></td></tr></table>"
	end if
	set dataListObj = nothing
End Sub

Sub add
%>
<form action="?action=add" method="post" >
<table class="tb mt20">
<tr class="thead"><th colspan="2">添加家庭成员</th></tr>
    <TR>
      <TD vAlign=center width="20%" >用户名(登录名):</TD>
      <TD ><input type="text" size="30" name="UserName" id="UserName"  onBlur="isExistUsername('')"/><span id="checkmanagername" style="color:#FF0000"><font color="red">*</font></span></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" >真实名:</TD>
      <TD ><input type="text" size="30" name="realName" id="realName" /><font color="red">*</font></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" >生日:</TD>
      <TD ><input type="text" size="30" name="birthday"/><span  style="color:#FF0000"><font color="red">*</font></span>如,2010-09-08</TD>
    </TR>
    <TR>
      <TD >密码:</TD>
      <TD ><input type="password" size="30" name="Password" /><font color="red">*</font></TD>
    </TR>
   
   <TR>
      <TD >密码确认:</TD>
      <TD ><input type="password" size="30" name="Password2" /><font color="red">*</font></TD>
    </TR>
    <TR>
      <TD >家庭成员级别:</TD>
      <TD ><label><input type="radio" size="20" name="AdminPower"  value="0" checked class="radio"/>户主(<font color="red">拥有全部权限</font>)</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" size="20" name="AdminPower" value="1" class="radio" />成员(<font color="red">只拥有数据管理权限</font>)</label><font color="red">*</font></TD>
    </TR>
    
    <TR align="center"  >
    <TD align="left" ></TD>
      <TD align="left" ><input type="submit" value="添加家庭成员" class="btn" />
      &nbsp;<input type="button" value="返   回"  class="btn" onClick="javascript:history.go(-1)" /></TD>
    </TR>
</td></tr></table>
</form>
<%
End Sub

Sub edit
	id=getForm("id","get")
	dim rsObj : set rsObj=conn.db("select * from {pre}Admin where ID="&id,"execute")
%>
<form action="?action=save&id=<%=id%>" method="post" name="editmanager" >
<table class="tb mt20">
<tr class="thead"><th colspan="2">编辑家庭成员</th></tr>
    <TR>
      <TD vAlign=center width="20%" >用户名:</TD>
      <TD ><input type="text" size="30" name="UserName"   value="<%=rsObj("UserName")%>" onBlur="isExistUsername('<%=id%>')"/><span id="checkmanagername" style="color:#FF0000"><font color="red">*</font></span></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" >真实名:</TD>
      <TD ><input type="text" size="30" name="realName"   value="<%=rsObj("realName")%>"/><span id="checkmanagername" style="color:#FF0000"><font color="red">*</font></span></TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" >生日:</TD>
      <TD ><input type="text" size="30" name="birthday"   value="<%=rsObj("birthday")%>"/><span  style="color:#FF0000"><font color="red">*</font></span>如,2010-09-08</TD>
    </TR>
    <TR>
      <TD >密码:</TD>
      <TD ><input type="password" size="30" name="Password"   value="" /><font color="red">*</font>不修改密码可不填</TD>
    </TR>
   
   <TR>
      <TD >密码确认:</TD>
      <TD ><input type="password" size="30" name="Password2" value="" /><font color="red">*</font>不修改密码可不填</TD>
    </TR>
    <TR>
      <TD >家庭成员级别:</TD>
      <TD ><label><input type="radio" size="20" name="AdminPower" class="radio"  value="0" <% if rsObj("AdminPower")=0 then %> checked <%end if%>/>户主(<font color="red">拥有全部权限</font>)</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" class="radio" size="20" name="AdminPower" value="1"  <% if rsObj("AdminPower")=1 then %> checked <%end if%> />成员(<font color="red">只拥有内容管理权限</font>)</label><font color="red">*</font></TD>
    </TR>
     <TR>
      <TD >是否锁定</TD>
      <TD ><label><input type="radio" class="radio" size="20" name="Working"  value="1" <% if rsObj("Working")=1 then %> checked <%end if%>/>激活</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" class="radio" size="20" name="Working" value="0"  <% if rsObj("Working")=0 then %> checked <%end if%> />锁定</label><font color="red">*</font></TD>
    </TR>
    <TR align="center"  >
    <TD align="left" ></TD>
      <TD align="left" ><input type="submit" value="修改家庭成员" name="m_eidtsubmit" class="btn" id="m_eidtsubmit" /><input type="hidden" name="passwordnow1" value="<%=rsObj("Password")%>">
      &nbsp;<input type="button" value="返   回"  class="btn" onClick="javascript:history.go(-1)" /></TD>
    </TR>
</td></tr></table>
</form>
<script>$("m_eidtsubmit").focus()</script>
<%
End Sub


Sub saveEdit
	dim UserName,realName,birthday,Password,Password2,AdminPower,Working,sqlStr,num,passwordnow,passwordnow1
	UserName = getForm("UserName","post"):realName = getForm("realName","post"):birthday = getForm("birthday","post"):passwordnow1 = getForm("passwordnow1","post"):Password = getForm("Password","post"): Password2 = getForm("Password2","post") :AdminPower = getForm("AdminPower","post") : Working=getForm("Working","post") : id=getForm("id","get")
	if   isNul(UserName)  or isNul(realname)   then  die errorInfo
	if Password<>Password2 then die errorPwd
	if isNul(AdminPower) then AdminPower=0
	if isNul(Working) then Working=1
    if Not isNul(Password) then passwordnow=md5(Password)
If isNul(Password) then passwordnow=passwordnow1
	num = conn.db("select count(*) from {pre}Admin where ID<>"&id&" and UserName='"&UserName&"'","execute")(0)
	if num>0 then die "已经存在此家庭成员,请更换名称"
	sqlStr = "update {pre}Admin set [UserName]='"&UserName&"',[realName]='"&realName&"',[birthday]='"&birthday&"',[Password]='"&Passwordnow&"',[AdminPower]="&AdminPower&",[Working]="&Working&" where ID="&id
	conn.db sqlStr,"execute" 
	alertMsg "编辑成功","admin_manager.asp?id="&id
End Sub


Sub addManager
	dim UserName,realname,birthday,Password,Password2,AdminPower,sqlStr,num
	UserName = getForm("UserName","post"):realName = getForm("realName","post"):birthday = getForm("birthday","post"):Password = getForm("Password","post"): Password2 = getForm("Password2","post") :AdminPower = getForm("AdminPower","post")
	if isNul(UserName) or isNul(Password) or isNul(Password2) then  die errorInfo
	if Password<>Password2 then die errorPwd
	if isNul(AdminPower) then AdminPower=0
	num = conn.db("select count(*) from {pre}Admin where UserName='"&UserName&"'","execute")(0)
	if num>0 then die "已经存在此家庭成员,请更换名称"
	sqlStr = "insert into {pre}Admin ([UserName],[realName],[birthday],[Password],[AdminPower],[Working]) values ('"&UserName&"','"&realName&"','"&birthday&"','"&md5(Password)&"',"&AdminPower&",1)"
	conn.db sqlStr,"execute" 
	alertMsg "添加成功","admin_manager.asp" 
End Sub

Sub delmanager
	dim UserName
	id=getForm("id","get")
	UserName = conn.db("select UserName from {pre}Admin where ID="&id,"execute")(0)
	if UserName=rCookie("UserName") then 
		alertMsg "不能删除自身","admin_manager.asp?id="&id
	else
		conn.db "delete from {pre}Admin where ID="&id,"execute" 
		alertMsg "","admin_manager.asp"
	end if
End Sub

Sub delAll
	dim ids,num,idsArray,idsArraylen,i,UserName : ids=replaceStr(getForm("m_id","post")," ","")
	idsArray=split(ids,",") : idsArraylen=ubound(idsArray)
	for i=0 to idsArrayLen
		UserName = conn.db("select UserName from {pre}Admin where ID="&idsArray(i),"execute")(0)
		if UserName<>rCookie("UserName") then  conn.db "delete from {pre}Admin where ID="&idsArray(i),"execute" 
	next
	alertMsg "","admin_manager.asp"
End Sub

Function getManagerLevel(id)
	if isNul(id) then getManagerLevel="未知" : Exit Function
	if id=0 then getManagerLevel="户主" : Exit Function
	if id=1 then getManagerLevel="成员" : Exit Function
End Function

Function getManagerState(id)
	if isNul(id) then getManagerState="未知" : Exit Function
	if id=0 then getManagerState="锁定" : Exit Function
	if id=1 then getManagerState="激活" : Exit Function
End Function
%>